﻿using PoemGame.Domain.Seedwork;

namespace PoemGame.Domain.GameAggregate
{
    /// <summary>
    /// 游戏中的玩家
    /// </summary>
    public class PlayerInGame:EntityBase
    {
        
        /// <summary>
        /// 玩家ID
        /// </summary>
        public Guid PlayerId { get; private set; }
        /// <summary>
        /// 游戏ID
        /// </summary>
        public Guid GameId { get; private set; }

        public string UserName { get; private set; } = "";
        /// <summary>
        /// 状态
        /// 轮到、等待、出局
        /// </summary>
        public PlayerGameStatus PlayerStatus { get; set; }
        /// <summary>
        /// 顺序
        /// </summary>
        public int Index { get;  set; }
        /// <summary>
        /// 是否创建者
        /// </summary>
        public bool IsCreator { get; private set; }
        /// <summary>
        /// 是否赢家
        /// </summary>
        public bool IsWinner { get; private set; }

        private PlayerInGame()
        {

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameId"></param>
        /// <param name="playerId"></param>
        public PlayerInGame(Guid gameId, Guid playerId, string userName,bool isCreator,int index)
        {
            GameId = gameId;
            PlayerId = playerId;
            UserName = userName;
            IsCreator = isCreator;
            PlayerStatus = PlayerGameStatus.Waiting;
            Index = index;  
        }

        public void SetWinner()
        {
            IsWinner = true;
        }
    }
}
